package com.eve.controller;

import java.io.FileNotFoundException;
import java.io.IOException;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.Map;

import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.support.SessionStatus;

import com.eve.crp.ClientFilter;

@Controller
public class HomeController extends BaseController {
	@RequestMapping(method=RequestMethod.GET,value="internal/home.html")
	public String initForm(ModelMap model){
		ClientFilter clientFilter = new ClientFilter();
		clientFilter.setSearch(false);
		//It appears as if the clientDao is not working to get the case list WHy?
		Map<String, Object> attributeList = new HashMap<String, Object>();
		attributeList.put("ClientList", clientDao.getCaseList(clientFilter));
		attributeList.put("ClientFilter", clientFilter);
		model.addAllAttributes(attributeList);
		System.out.println("Model is loaded");
		return "internal/home";
	}
	@RequestMapping(value="inernal/homeFilter.html", method = RequestMethod.POST)
	public String processSubmit(@ModelAttribute("ClientFilter") ClientFilter clientFilter, BindingResult result, SessionStatus status) throws FileNotFoundException, ClassNotFoundException, SQLException, IOException{
		
		return "internal/home";
	}
}
